import Vue from 'vue'
import VueRouter from 'vue-router'

//启用vue-router功能
Vue.use(VueRouter);

//配置路由表
export default new VueRouter({
    //使用懒加载模式进行路由
    routes: [
        /* 主页 */
        { 
            path: "/", 
            name: "Home",
            component: resolve => (require(["@/views/Home"], resolve))
        },
        /* 技术专栏 */
        { 
            path: "/technical", 
            name: "Technical",
            component: resolve => (require(["@/views/Technical"], resolve))
        },
        /* 程序人生 */
        { 
            path: "/life", 
            name: "Life",
            component: resolve => (require(["@/views/Life"], resolve))
        },
        /* 文章归档 */
        { 
            path: "/timeline", 
            name: "TimeLine",
            component: resolve => (require(["@/views/TimeLine"], resolve))
        },
        /* 文章详情 */
        {
            path: "/articleInfo/:id",
            name: "ArticleInfo",
            props: true,
            component: resolve => (require(["@/views/ArticleInfo"], resolve))
        },
        /* 搜索内容 */
        {
            path: "/search",
            name: "Search",
            component: resolve => (require(["@/views/Search"], resolve))
        },
    ]
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}